<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>素材库</title>
    <link rel="icon" href="__FORJS__/images/favicon.ico">
    <link rel="stylesheet" href="__FORJS__/css/common/bootstrap.min.css"/>
    <link rel="stylesheet" href="__FORJS__/css/common/global.css"/>
    <link rel="stylesheet" href="__FORJS__/css/common/icon-style.css"/>
    <link rel="stylesheet" href="__FORJS__/css/common/ali-icon-style.css"/>
    <link rel="stylesheet" href="__FORJS__/css/individual/video-preview.css"/>

    <script src="__FORJS__/js/common/jquery-1.9.1.min.js"></script>
    <script src="__FORJS__/js/common/jquery.SuperSlide.js"></script>
    <script src="__FORJS__/js/common/bigwe_function.js"></script>
</head>
<body>
<div class="bw_main">
    <!--通知栏-->
    <include file="./Application/Home/View/Common/header.html" />

    <!--通知下面的所有区域-->

    <foreach name="video" item="item">
        <div class="video-play-wrap">
            <div class="video-play">
                <video src="{$item['address']}" controls="controls" class="video-js" style="width:100%;"></video>
            </div>
            <div class="video-guild">
                <input id="video_id" type="hidden" value="{$item['pid']}">
                <h5>{$item['title']}</h5>
                <p class="video-source">
                    <span class="iconfont">&#xe62c;</span>
                    <span>{$item['author']}</span>
                    <span class="iconfont golden">&#xe659;</span>
                </p>
                <span class="source-time">{$item['time']}</span>
                <span class="reading-number">来源：<span>微知</span></span>
                <foreach name="item['label']" item="label">
                    <a>{$label}</a>
                </foreach>
                <p class="video-synopsis">
                    {$item['synopsis']}
                </p>
                <p class="video-preview"><span class="icon-Preview"></span><span>{$item['read_num']}</span></p>
                <if condition="in_array($item['author'], $item['my_liked'])">
                    <p class="video-praise golden"><span class="iconfont">&#xf010d;</span><span>{$item['like_num']}</span></p>
                    <else />
                    <p class="video-praise"><span class="iconfont">&#xf010d;</span><span>{$item['like_num']}</span></p>
                </if>
                <if condition="in_array($item['address'], array_column(json_decode($my_video, TRUE), 'address'))">
                    <button class="bigwe_default_btn video-collection">已加入收藏</button>
                    <else />
                    <button class="bigwe_default_btn video-collection">加入收藏</button>
                </if>
            </div>
            <div class="video-map">
                <div class="video-map-list">
                    <!--<div class="video-sub">
                        <input type="hidden" class="video_id" value="<?php echo $video[0]->video_id;?>">
                        <input type="hidden" class="user_login" value="<?php echo $video[0]->user_login;?>">
                        <img src="http://192.168.2.124/userUploadImage/16b68b6fc5d36409edc6f498d2a90581.jpg">
                        <p><?php echo $video[0]->title?></p>
                    </div>
                    foreach($all_video as $all){
                        echo '<div class="video-sub">
                    <input type="hidden" class="video_id" value="'.$all->video_id.'">
                    <input type="hidden" class="user_login" value="'.$all->user_login.'">
                    <img src="http://192.168.2.124/userUploadImage/16b68b6fc5d36409edc6f498d2a90581.jpg">
                    <p>'.$all->title.'</p>
                </div>-->
                </div>
                <div class="banner-btn prev"><span class="glyphicon glyphicon-triangle-left"></span></div>
                <div class="banner-btn next"><span class="glyphicon glyphicon-triangle-right"></span></div>
            </div>
        </div>
    </foreach>
</div>
<!--页面底部-->
<include file="./Application/Home/View/Common/footer.html" />
<script>
    $(function () {
        $(".video-map").slide({
            mainCell: ".video-map-list",
            vis: 6,
            scroll: 6,
            autoPage:true,
            effect: "left"
        })
        $.get('/VideoPreview/get_all_video',{},function(data){
            var obj = eval("(" + data + ")");
            $('.video-map-list').html(obj.content);
            hover();
        });
    });

    function hover(){
        $(".video-sub").hover(function () {
            $(this).children("img").css({opacity: 1});
            $(this).append("<div class='img-play'><span class='iconfont'>&#xe633;</span></div>");
            $(".img-play").click(function () {
                var video_id=$(this).parent().attr('video-id');
                var user_login=$(this).parent().attr('user-login');
                $.get('/VideoPreview/get_video',{video_id:video_id,user_login:user_login},function(data){
                    var obj = eval("("+data+")");
                    $('.video-guild').html(obj.content);
                    $('.video-play').html(obj.video_play);
                });
            })
        }, function () {
            $(this).children("img").css({opacity: 0.5});
            $(".img-play").remove();
        })
    }
    hover();
    $(".video-guild").on("click",".video-praise .iconfont", function () {
        var number = parseInt($(this).siblings().text());
        var video_id=$('#video_id').val();
        if ($(this).parent().hasClass("golden")){
            $(this).parent().removeClass("golden");
            $(this).siblings().text(number - 1);
            $.post("/resource/click_like", {article_id: video_id, like_num:(number - 1),type:'video', done: 'delete'}, function (data) {
            });
        }else {
            $(this).parent().addClass("golden");
            $(this).siblings().text(number + 1);
            $.post("/resource/click_like", {article_id: video_id, like_num:(number + 1),type:'video', done: 'add'}, function (data) {
            });
        }
    })
    $(".video-guild").on("click" ,".video-collection" ,function(){
        if($(this).text() == '已加入收藏'){
            ShowTitleMessage.show('您已收藏过该视频，可以在我的素材页面查看！', showTime);
        }else{
            var video_id = $('#video_id').val();
            var user_login = $('.video-source').children('span:eq(1)').text();
            $.post("/resource/add_my_video", {video_id: video_id, user_login: user_login}, function (data) {
            });
            $(this).text("已加入收藏");
        }

    })
</script>
</body>
</html>